import java.util.*;

public class StudentRecordsSystem 
{
	ArrayList<Student> students;
	StudentRecordsFrame gui;

	public StudentRecordsSystem(StudentRecordsFrame guiIn)
	{
		gui = guiIn;
		students = new ArrayList<Student>();
	}
		
	public void addStudent(String name,String address,String phone)
	{
		Student student = new Student(name,address,phone);
		students.add(student);
	}
	
	public void search(String name)
	{
		Student matchingStudent=null;
		for(int i=0; i<students.size(); i++)
		{
			Student student = students.get(i);
			if(student.getName().equals(name))
			{
				gui.setDetails(name, student.getAddress(),student.getPhone());
				matchingStudent = student;
			}
		}
		
		
		if(matchingStudent==null)
		{
			gui.showMessage("Not found");
		}
	}
}
